package com.medical.literature.user.controller;

import com.medical.literature.common.vo.Result;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 密码测试控制器
 */
@Slf4j
@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class PasswordTestController {
    
    private final PasswordEncoder passwordEncoder;

    /**
     * 测试密码验证
     */
    @GetMapping("/password")
    public Result<String> testPassword(@RequestParam String rawPassword, @RequestParam String dbPassword) {
        boolean matches = passwordEncoder.matches(rawPassword, dbPassword);
        log.info("原始密码: {}", rawPassword);
        log.info("数据库密码: {}", dbPassword);
        log.info("密码匹配结果: {}", matches);
        
        return Result.success("密码匹配结果: " + matches);
    }
}